/**
 * 
 */
package com.ksframework.security.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.ksframework.common.entity.BaseEntity;

/**
 * @description
 * @author ssocenter
 * @date 2011-8-26
 */
@SuppressWarnings("serial")
@Entity
@Table(name="security_user")
public class User extends BaseEntity {
	public enum UserMode{
		enable,
		disable
	}
	private String name;
	private String account;
	private String password;
	private UserMode enabled;
	private Set<Role> roles = new HashSet<Role>();
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Enumerated(EnumType.ORDINAL)
	public UserMode getEnabled() {
		return enabled;
	}
	public void setEnabled(UserMode enabled) {
		this.enabled = enabled;
	}
	@ManyToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
}
